package per.ethan.cloud.provider.core.stream.impl;

import cn.hutool.core.util.IdUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import per.ethan.cloud.provider.core.stream.MessageProvider;

/**
 * @author Ethan
 * @date 2020/03/31 18:16
 */
@Slf4j
@EnableBinding(Source.class)
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class MessageProviderImpl implements MessageProvider {

    private final MessageChannel output;

    @Override
    public void send() {
        String uuid = IdUtil.randomUUID();
        output.send(MessageBuilder.withPayload(uuid).build());
        log.info("randomUUID: {}", uuid);
    }

}
